import 'package:flutter/material.dart';
import 'package:flutter_project/common/utils/screen_size_utils.dart';
import 'package:flutter_project/config/theme_color.dart';

class SignUpDialogView {
  static double itemWidth = 60;

  static showSignView(BuildContext context) {
    List<int> moneyList = [30, 50, 80, 100];
    List<String> dayList = ['今天', '第2天', '第3天', '第4天'];
    return showDialog(
        context: context,
        builder: (BuildContext context) {
          return Center(
            child: Container(
              width: ScreenSizeUtils.deviceScreenWidth(context) - 50,
              height: 360,
              decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(16), color: Colors.white),
              padding: const EdgeInsets.only(left: 13, right: 13, top: 15),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Row(
                    children: [
                      Icon(
                        Icons.sick_rounded,
                        color: ThemeColor.orangeColor,
                        size: 17,
                      ),
                      const SizedBox(
                        width: 5,
                      ),
                      Text(
                        '今日签到',
                        style: TextStyle(
                            fontSize: 18,
                            fontWeight: FontWeight.w500,
                            color: ThemeColor.orangeColor),
                      ),
                      const Spacer(),
                      GestureDetector(
                        child: const Icon(Icons.close),
                        onTap: () {
                          Navigator.pop(context);
                        },
                      )
                    ],
                  ),
                  const SizedBox(
                    height: 5,
                  ),
                  RichText(
                    text: TextSpan(
                        text: '已连续签到',
                        style: TextStyle(
                            color: ThemeColor.textColorSecond, fontSize: 13),
                        children: [
                          TextSpan(
                            text: '0/7',
                            style: TextStyle(
                                color: ThemeColor.orangeColor,
                                fontSize: 13,
                                fontWeight: FontWeight.w500),
                          ),
                          TextSpan(
                            text: '次,明日签到再得',
                            style: TextStyle(
                              color: ThemeColor.textColorSecond,
                              fontSize: 13,
                            ),
                          ),
                          TextSpan(
                            text: '50',
                            style: TextStyle(
                                color: ThemeColor.orangeColor,
                                fontSize: 13,
                                fontWeight: FontWeight.w500),
                          ),
                          TextSpan(
                            text: '金币',
                            style: TextStyle(
                              color: ThemeColor.textColorSecond,
                              fontSize: 13,
                            ),
                          ),
                        ]),
                  ),
                  const SizedBox(
                    height: 15,
                  ),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceAround,
                    children:
                        getListWidget(dataList: moneyList, todayList: dayList),
                  ),
                  const SizedBox(
                    height: 15,
                  ),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceAround,
                    children: [
                      getItemView(name: "100", timer: '第5天'),
                      getItemView(name: "120", timer: '第6天'),
                      Column(
                        children: [
                          Container(
                            alignment: Alignment.center,
                            width: itemWidth * 2,
                            height: itemWidth,
                            decoration: BoxDecoration(
                              borderRadius: BorderRadius.circular(8),
                              color: Colors.yellowAccent,
                            ),
                            child: const Text(
                              '+150',
                              style: TextStyle(
                                  color: Color.fromRGBO(201, 86, 60, 1.0),
                                  fontWeight: FontWeight.w500,
                                  fontSize: 17),
                            ),
                          ),
                          const SizedBox(
                            height: 5,
                          ),
                          Text(
                            '第7天',
                            style: TextStyle(
                                fontSize: 13,
                                color: ThemeColor.textColorSecond),
                          )
                        ],
                      ),
                    ],
                  ),
                  const SizedBox(
                    height: 25,
                  ),
                  Center(
                    child: ElevatedButton(
                      style: ButtonStyle(
                          backgroundColor:
                              MaterialStatePropertyAll(ThemeColor.orangeColor),
                          padding: const MaterialStatePropertyAll(
                              EdgeInsets.symmetric(
                                  horizontal: 60, vertical: 13))),
                      onPressed: () {},
                      child: const Text(
                        '立即签到 +30金币',
                        style: TextStyle(
                            color: Colors.white,
                            fontSize: 17,
                            fontWeight: FontWeight.bold),
                      ),
                    ),
                  ),
                ],
              ),
            ),
          );
        });
  }

  static List<Widget> getListWidget(
      {required List<int> dataList, required List<String> todayList}) {
    return List.generate(
        dataList.length,
        (index) => getItemView(
            name: dataList[index].toString(), timer: todayList[index]));
  }

  static Widget getItemView({required String name, required String timer}) {
    return Column(
      children: [
        Container(
          alignment: Alignment.center,
          width: itemWidth,
          height: itemWidth,
          decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(8),
            color: Colors.yellowAccent,
          ),
          child: Text(
            '+$name',
            style: const TextStyle(
                color: Color.fromRGBO(201, 86, 60, 1.0),
                fontWeight: FontWeight.w500,
                fontSize: 17),
          ),
        ),
        const SizedBox(
          height: 5,
        ),
        Text(
          timer,
          style: TextStyle(fontSize: 13, color: ThemeColor.textColorSecond),
        )
      ],
    );
  }
}
